'''
py3.5 使用pymysql连接mysql，因为mysql官方没有py3.5的驱动
命令：conda install pymysql
'''
import pymysql.cursors

config = {
    'host': '127.0.0.1',
    'port': 3306,
    'user': 'root',
    'password': 'root',
    'db': 'note',
    'cursorclass': pymysql.cursors.DictCursor,
}

# Connect to the database
connection = pymysql.connect(**config)
print(connection)
with connection.cursor() as cursor:
    sql = 'select * from cn_user'
    cursor.execute(sql)
    result = cursor.fetchall()
    print(result)
    connection.commit()
connection.close()